package top.callname.util;

import org.apache.log4j.Logger;

import top.callname.service.NoticeService;
import top.callname.service.impl.NoticeServiceImpl;

/**
 * 定时推送公告任务
 */
public class NoticeSendThread implements Runnable {

	private final Logger logger = Logger.getLogger(NoticeSendThread.class);
	/**
	 * 50秒扫描一次任务
	 */
	private final static int TIEME_OUT = 1 * 50 * 1000;
	private final NoticeService noticeService = new NoticeServiceImpl();

	public void run() {
		while (true) {
			try {
				noticeService.sendNoticeTask();
				Thread.sleep(TIEME_OUT);
			} catch (Exception e) {
				try {
					Thread.sleep(TIEME_OUT);
				} catch (InterruptedException e1) {
					logger.error("{}", e1);
				}
				logger.error("{}", e);
			}
		}
	}

}